home *** CD-ROM | disk | FTP | other *** search
/ Champak 114 / Vol 114.iso / games / park_thi.swf / scripts / DefineSprite_808 / frame_1 / DoAction.as
Encoding:
Text File  |  2010-08-12  |  2.0 KB  |  79 lines

  1. var prevX = this._x;
  2. var prevY = this._y;
  3. var speed = 7;
  4. var hit = false;
  5. var block = false;
  6. onEnterFrame = function()
  7. {
  8.    if(_visible)
  9.    {
  10.       if(_root.userCar != "")
  11.       {
  12.          _root.userCar = "";
  13.       }
  14.       if(!hit)
  15.       {
  16.          prevX = this._x;
  17.          prevY = this._y;
  18.          if(Key.isDown(37) && !Key.isDown(39))
  19.          {
  20.             target_mc.gotoAndPlay(2);
  21.             _X = _X - speed;
  22.             _rotation = 90;
  23.          }
  24.          if(Key.isDown(39) && !Key.isDown(37))
  25.          {
  26.             target_mc.gotoAndPlay(2);
  27.             _X = _X + speed;
  28.             _rotation = 270;
  29.          }
  30.          if(Key.isDown(38) && !Key.isDown(40))
  31.          {
  32.             target_mc.gotoAndPlay(2);
  33.             _Y = _Y - speed;
  34.             _rotation = 180;
  35.          }
  36.          if(Key.isDown(40) && !Key.isDown(38))
  37.          {
  38.             target_mc.gotoAndPlay(2);
  39.             _Y = _Y + speed;
  40.             _rotation = 0;
  41.          }
  42.          if(Key.isDown(37) && Key.isDown(38) && !Key.isDown(39) && !Key.isDown(40))
  43.          {
  44.             target_mc.gotoAndPlay(2);
  45.             _X = _X + speed / 4;
  46.             _Y = _Y + speed / 4;
  47.             _rotation = 135;
  48.          }
  49.          if(Key.isDown(39) && Key.isDown(38) && !Key.isDown(37) && !Key.isDown(40))
  50.          {
  51.             target_mc.gotoAndPlay(2);
  52.             _X = _X - speed / 4;
  53.             _Y = _Y + speed / 4;
  54.             _rotation = 225;
  55.          }
  56.          if(Key.isDown(37) && Key.isDown(40) && !Key.isDown(39) && !Key.isDown(38))
  57.          {
  58.             target_mc.gotoAndPlay(2);
  59.             _X = _X + speed / 4;
  60.             _Y = _Y - speed / 4;
  61.             _rotation = 45;
  62.          }
  63.          if(Key.isDown(39) && Key.isDown(40) && !Key.isDown(37) && !Key.isDown(38))
  64.          {
  65.             target_mc.gotoAndPlay(2);
  66.             _X = _X - speed / 4;
  67.             _Y = _Y - speed / 4;
  68.             _rotation = 315;
  69.          }
  70.       }
  71.       else
  72.       {
  73.          this._x = prevX;
  74.          this._y = prevY;
  75.          hit = false;
  76.       }
  77.    }
  78. };
  79.